﻿#pragma checksum "C:\Users\Samuel\Desktop\UPC\Pruebas\SolucionDemoASPNet01\SolucionDemoASPNet01\DemoASPNet01\Default.aspx.cs" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "07E618C54FD243CBBE80C75A125F1290591A4DB0"

#line 1 "C:\Users\Samuel\Desktop\UPC\Pruebas\SolucionDemoASPNet01\SolucionDemoASPNet01\DemoASPNet01\Default.aspx.cs"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{

    int respuesta;
  
    public void Page_Load(object sender, EventArgs e)
    {

    }

    protected String Generasim()
    {
        Random ran = new Random();
        int numero = ran.Next(1, 3);
        string oper;

        if (numero == 1)
        {
            oper = "+";

        }
        else
            if (numero == 2)
            {
               
                oper = "-";
            }
            else
                if (numero == 3)
                {
                    
                    oper = "*";
                }
                else
                    return " ";
        return oper;

    }
    protected int Sumar(int a, int b)
    {
        return a + b;
    }
    protected int Restar(int a, int b)
    {
        return a - b;    
    }
    protected int Multiplicar(int a, int b)
    {
        return a * b;
    }

    protected int Operacion(int a, string oper, int b)
    {
       int resp = 0;
       if(oper.Equals("+"))
        {
            resp = a + b;
        }
        else
            if (oper.Equals("-"))
            {
                resp = a - b;
                
            }
            else
                if (oper.Equals("*"))
                {
                    resp = a * b;
                    
                }
                else
                    return 0;
        return resp;

    }
    protected int Generanum1()
    {

        Random ran = new Random(DateTime.Now.Millisecond);
        int numero = ran.Next(0, 55);

        return numero;
    }
    protected int Generanum2()
    {
      
        Random ran = new Random(DateTime.Now.Millisecond);
        int numero = ran.Next(56, 99);

        return numero;
    }
      
    protected void btnSaludar_Click(object sender, EventArgs e)
    {
        int n1 = Generanum1();
        int n2 = Generanum2();
        string sim = Generasim();
        respuesta = Operacion(n1, sim, n2);

        lblerror.Visible = false;

        lblpregunta.Visible = true;
        lblpregunta.Text = "Cuanto es: " + Convert.ToString(n1) + sim + Convert.ToString(n2);
        btnpregunta.Visible = true;
        btnpregunta.Text = "Saludar";
        txtrespuesta.Visible = true;
        lblrespuesta.Text = Convert.ToString(respuesta);
    }

    protected void btnpregunta_click(object sender, EventArgs e)
    {
        lblerror.Visible = false;

        try
        {
            if (txtrespuesta.Text == lblrespuesta.Text)
                lblSaludo.Text = "Hola " + txtNombre.Text;
            else
                lblSaludo.Text = "GAME OVER";
        }
        catch (Exception ex)
        {
            lblerror.Visible = true;
        }
    }
}

#line default
#line hidden
